<template>
	<div>
		<h2>商品详情</h2>
		<h4>商品名称：{{item.itemName}}</h4>
		<h4>剩余商品数量：{{item.total}}</h4>
		<h4>开始时间：{{item.startTime}}</h4>
		<h4>结束时间：{{item.endTime}}</h4>
		<el-button type="danger" @click="toKill(item.id)" v-if="item.canKill==1">秒杀</el-button>
		<el-button type="danger" v-else>抢购结束或未开始</el-button>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				item: {
					itemId: 1001,
					itemName: '卫龙辣条',
					total: 10,
					startTime: '2021-12-01 20:10:10',
					endTime: '2021-12-07 05:14:23',
					canKill: 1
				}
			}
		},
		mounted: function() {
			var that = this;
			var itemId = this.$route.query.itemId;
			this.$http.get('/itemDetail/'+itemId).then(function(res) {
				that.item = res.data.data;
			}).catch(function(err) {
				console.log("err", err);
			})
		},
		methods: {
			toKill: function(id){
				this.$http.post('/toKill',{"id":id}).then(function(res) {
					
				}).catch(function(err) {
					console.log("err", err);
				})
			}
		}
	}
</script>

<style>
</style>
